
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>3.3 副本集(ReplicaSet) · Kubernetes - 痴者工良</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="痴者工良">
        
        
    
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-insert-logo/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-advanced-emoji/emoji-website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-alerts/style.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-prism/prism.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    


    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="4.pod_network.html" />
    
    
    <link rel="prev" href="2.deployment.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    
    
        
        <li>
            <a href="https://www.whuanle.cn" target="_blank" class="custom-link">痴者工良的博客</a>
        </li>
    
    

    
    <li class="divider"></li>
    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    文档说明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../1.basic/">
            
                <a href="../1.basic/">
            
                    
                    1.基础知识
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../1.basic/">
            
                <a href="../1.basic/">
            
                    
                    导读
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../1.basic/1.docker.html">
            
                <a href="../1.basic/1.docker.html">
            
                    
                    1.1 说透 Docker：基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../1.basic/2.virtual.html">
            
                <a href="../1.basic/2.virtual.html">
            
                    
                    1.2 说透 Docker： 虚拟化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="../1.basic/3.docker_network.html">
            
                <a href="../1.basic/3.docker_network.html">
            
                    
                    1.3 了解 Docker 网络
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="../1.basic/4.pod_docker.html">
            
                <a href="../1.basic/4.pod_docker.html">
            
                    
                    1.4 Docker 和 Pod
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="../1.basic/5.k8s.html">
            
                <a href="../1.basic/5.k8s.html">
            
                    
                    1.5 K8S入门基础
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../2.deploy/">
            
                <a href="../2.deploy/">
            
                    
                    2.部署和配置
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../2.deploy/2.deploy.md">
            
                <span>
            
                    
                    导读
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../2.deploy/1.minikube.html">
            
                <a href="../2.deploy/1.minikube.html">
            
                    
                    2.1 使用 Minikube 部署
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../2.deploy/2.kubeadm.html">
            
                <a href="../2.deploy/2.kubeadm.html">
            
                    
                    2.2 使用 kubeadm 部署
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../2.deploy/3.kubeadm_ckad.html">
            
                <a href="../2.deploy/3.kubeadm_ckad.html">
            
                    
                    2.3 CKAD认证中的部署教程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="../2.deploy/4.kubeadm_proxy.html">
            
                <a href="../2.deploy/4.kubeadm_proxy.html">
            
                    
                    2.4 国内代理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="../2.deploy/5.dashboard.html">
            
                <a href="../2.deploy/5.dashboard.html">
            
                    
                    2.5 Dashboard
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="./">
            
                <a href="./">
            
                    
                    3.Pod部署和调度
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="./">
            
                <a href="./">
            
                    
                    导读
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="1.pod.html">
            
                <a href="1.pod.html">
            
                    
                    3.1 Pod
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="2.deployment.html">
            
                <a href="2.deployment.html">
            
                    
                    3.2 Deployment部署
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.4.4" data-path="3.replica.html">
            
                <a href="3.replica.html">
            
                    
                    3.3 副本集(ReplicaSet)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="4.pod_network.html">
            
                <a href="4.pod_network.html">
            
                    
                    3.34 Pod 端口映射
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="5.update.html">
            
                <a href="5.update.html">
            
                    
                    3.5 Pod 升级、回滚
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7" data-path="6.scale.html">
            
                <a href="6.scale.html">
            
                    
                    3.6 Pod 缩放
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.8" data-path="7.lable.html">
            
                <a href="7.lable.html">
            
                    
                    3.7.Pod 标签
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.9" data-path="8.schedule.html">
            
                <a href="8.schedule.html">
            
                    
                    3.8 Pod 调度
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.10" data-path="9.jobs_cronjobs.html">
            
                <a href="9.jobs_cronjobs.html">
            
                    
                    3.9 Jobs、CronJobs
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../4.network/">
            
                <a href="../4.network/">
            
                    
                    4.Kubernetes 网络
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../4.network/">
            
                <a href="../4.network/">
            
                    
                    导读
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../4.network/1.network.html">
            
                <a href="../4.network/1.network.html">
            
                    
                    4.1 Kubernetes 网络
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../4.network/2.endpoint.html">
            
                <a href="../4.network/2.endpoint.html">
            
                    
                    4.2 Endpoint
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../4.network/3.ingress.html">
            
                <a href="../4.network/3.ingress.html">
            
                    
                    4.3 ingress
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="../4.network/4.discovery.html">
            
                <a href="../4.network/4.discovery.html">
            
                    
                    4.4 服务发现
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../5.volumes/">
            
                <a href="../5.volumes/">
            
                    
                    5.volumes
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../5.volumes/">
            
                <a href="../5.volumes/">
            
                    
                    导读
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../5.volumes/1.volumes.html">
            
                <a href="../5.volumes/1.volumes.html">
            
                    
                    5.1 卷
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../5.volumes/2.secret_configmap.html">
            
                <a href="../5.volumes/2.secret_configmap.html">
            
                    
                    5.2 secret 和 ConfigMap 卷
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../5.volumes/3.nfts.html">
            
                <a href="../5.volumes/3.nfts.html">
            
                    
                    5.3 NFS卷
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="../5.volumes/4.pv_pvc.html">
            
                <a href="../5.volumes/4.pv_pvc.html">
            
                    
                    5.4 持久化卷
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../6.api_safe/">
            
                <a href="../6.api_safe/">
            
                    
                    6.API 和 安全
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../6.api_safe/">
            
                <a href="../6.api_safe/">
            
                    
                    导读
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../7.health/">
            
                <a href="../7.health/">
            
                    
                    7.维护和故障排除
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../8.health/README.md">
            
                <span>
            
                    
                    导读
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../k8s.html">
            
                <a href="../k8s.html">
            
                    
                    Kubernetes 命令概览
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../ckad.html">
            
                <a href="../ckad.html">
            
                    
                    CKAD 认证帮助
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >3.3 副本集(ReplicaSet)</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><li><span class="title-icon "></span><a href="#33-&#x526F;&#x672C;&#x96C6;replicaset"><b></b>3.3 &#x526F;&#x672C;&#x96C6;(ReplicaSet)</a></li><ul><li><span class="title-icon "></span><a href="#&#x526F;&#x672C;&#x96C6;"><b></b>&#x526F;&#x672C;&#x96C6;</a></li><ul><li><span class="title-icon "></span><a href="#deployment-&#x4FDD;&#x62A4;-pod"><b></b>Deployment &#x4FDD;&#x62A4; Pod</a></li><li><span class="title-icon "></span><a href="#&#x6269;&#x5BB9;-pod"><b></b>&#x6269;&#x5BB9; Pod</a></li><li><span class="title-icon "></span><a href="#scale"><b></b>Scale</a></li><li><span class="title-icon "></span><a href="#daemonset"><b></b>DaemonSet</a></li><li><span class="title-icon "></span><a href="#&#x8D1F;&#x8F7D;&#x5747;&#x8861;"><b></b>&#x8D1F;&#x8F7D;&#x5747;&#x8861;</a></li><li><span class="title-icon "></span><a href="#replicationcontroller-&#x548C;-replicaset"><b></b>ReplicationController &#x548C; ReplicaSet</a></li></ul></ul></ul></div><h1 id="33-&#x526F;&#x672C;&#x96C6;replicaset"><a name="33-&#x526F;&#x672C;&#x96C6;replicaset" class="anchor-navigation-ex-anchor" href="#33-&#x526F;&#x672C;&#x96C6;replicaset"><i class="fa fa-link" aria-hidden="true"></i></a>3.3 &#x526F;&#x672C;&#x96C6;(ReplicaSet)</h1>
<p>ReplicaSet &#x4E5F;&#x662F;&#x4E00;&#x79CD;&#x7BA1;&#x7406; Pod &#x7684;&#x5BF9;&#x8C61;&#xFF0C;&#x8DDF;&#x4E0A;&#x4E00;&#x7AE0;&#x63D0;&#x5230;&#x7684; Deployment &#x4E00;&#x6837;&#xFF0C;&#x53EF;&#x4EE5;&#x5B88;&#x62A4; Pod &#xFF0C;&#x4FDD;&#x8BC1; Pod &#x6302;&#x4E86;&#x540E;&#x80FD;&#x591F;&#x6062;&#x590D;&#x3002;</p>
<h2 id="&#x526F;&#x672C;&#x96C6;"><a name="&#x526F;&#x672C;&#x96C6;" class="anchor-navigation-ex-anchor" href="#&#x526F;&#x672C;&#x96C6;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x526F;&#x672C;&#x96C6;</h2>
<p>ReplicaSet &#x4E3A;&#x526F;&#x672C;&#x96C6;&#x7684;&#x610F;&#x601D;&#xFF0C;Delpoyment &#x90E8;&#x7F72;&#x7684; Pod&#xFF0C;&#x53EF;&#x4EE5;&#x6307;&#x5B9A;&#x5176;&#x526F;&#x672C;&#x6570;&#x91CF;&#xFF0C;&#x526F;&#x672C;&#x6570;&#x91CF;&#x5C31;&#x662F;&#x8868;&#x793A;&#x90E8;&#x7F72;&#x591A;&#x5C11;&#x4E2A; Pod&#xFF0C;&#x4E00;&#x4E2A; Pod &#x6A21;&#x677F; &#x751F;&#x6210; N&#x4E2A; Pod &#x5B9E;&#x4F8B;&#xFF0C;&#x800C;&#x4E0D;&#x662F;&#x6307;&#x4E00;&#x4E2A;&#x539F;&#x578B;+&#x591A;&#x4E2A;&#x514B;&#x9686;&#xFF0C;&#x6570;&#x91CF;&#x662F; N&#xFF0C;&#x800C;&#x4E0D;&#x662F; N+1&#x3002;</p>
<h3 id="deployment-&#x4FDD;&#x62A4;-pod"><a name="deployment-&#x4FDD;&#x62A4;-pod" class="anchor-navigation-ex-anchor" href="#deployment-&#x4FDD;&#x62A4;-pod"><i class="fa fa-link" aria-hidden="true"></i></a>Deployment &#x4FDD;&#x62A4; Pod</h3>
<p>&#x524D;&#x9762;&#x6211;&#x4EEC;&#x5B66;&#x4E60;&#x5230; Deployment&#xFF0C;&#x4F7F;&#x7528; Deployment &#x90E8;&#x7F72; Pod&#xFF0C;&#x5F53; Pod &#x6216;&#x6240;&#x5728;&#x8282;&#x70B9;&#x51FA;&#x73B0;&#x6545;&#x969C;&#x65F6;&#xFF0C;Deployment &#x4F1A;&#x81EA;&#x52A8;&#x521B;&#x5EFA;&#x65B0;&#x7684; Pod&#x3002;</p>
<p>&#x6211;&#x4EEC;&#x6267;&#x884C; <code>kubectl get deployments</code> &#x547D;&#x4EE4;&#xFF0C;&#x8F93;&#x51FA;&#xFF1A;</p>
<pre class="language-"><code>NAME    READY   UP-TO-DATE   AVAILABLE   AGE
nginx   1/1     1            1           38m
</code></pre><ul>
<li><code>NAME</code> &#x5217;&#x51FA;&#x4E86;&#x96C6;&#x7FA4;&#x4E2D; Deployment &#x7684;&#x540D;&#x79F0;&#x3002;</li>
<li><code>READY</code> &#x663E;&#x793A;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x7684;&#x53EF;&#x7528;&#x7684; <em>&#x526F;&#x672C;</em> &#x6570;&#x3002;&#x663E;&#x793A;&#x7684;&#x6A21;&#x5F0F;&#x662F;&#x201C;&#x5C31;&#x7EEA;&#x4E2A;&#x6570;/&#x671F;&#x671B;&#x4E2A;&#x6570;&#x201D;&#x3002;</li>
<li><code>UP-TO-DATE</code> &#x663E;&#x793A;&#x4E3A;&#x4E86;&#x8FBE;&#x5230;&#x671F;&#x671B;&#x72B6;&#x6001;&#x5DF2;&#x7ECF;&#x66F4;&#x65B0;&#x7684;&#x526F;&#x672C;&#x6570;&#x3002;</li>
<li><code>AVAILABLE</code> &#x663E;&#x793A;&#x5E94;&#x7528;&#x53EF;&#x4F9B;&#x7528;&#x6237;&#x4F7F;&#x7528;&#x7684;&#x526F;&#x672C;&#x6570;&#x3002;</li>
<li><code>AGE</code> &#x663E;&#x793A;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x8FD0;&#x884C;&#x7684;&#x65F6;&#x95F4;&#x3002;</li>
</ul>
<p>&#x5982;&#x679C;&#x4F60;&#x4F7F;&#x7528;&#x547D;&#x4EE4;&#x521B;&#x5EFA; Deployment&#xFF0C;&#x5728; Pod &#x6CA1;&#x6709;&#x521B;&#x5EFA;&#x5B8C;&#x6210;&#x524D;&#xFF0C; <code>READY</code> &#x5B57;&#x6BB5;&#x53EF;&#x80FD;&#x663E;&#x793A;&#x4E3A; <code>0/1</code>&#x3002;</p>
<p>&#x8FD9;&#x662F;&#x56E0;&#x4E3A; Deployment &#x4E2D;&#x9ED8;&#x8BA4;&#x53EA;&#x7EF4;&#x62A4;&#x4E00;&#x4E2A; Pod &#x5B9E;&#x4F8B;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x67E5;&#x770B; Deployment &#x7684; YAML &#x6587;&#x4EF6;&#xFF0C;&#x627E;&#x5230;&#xFF1A;</p>
<pre class="language-"><code class="lang-yaml"><span class="token comment"># &#x67E5;&#x770B;&#x547D;&#x4EE4; kubectl get deployment nginx -o yaml</span>
<span class="token punctuation">...</span>
<span class="token key atrule">spec</span><span class="token punctuation">:</span>
  <span class="token key atrule">progressDeadlineSeconds</span><span class="token punctuation">:</span> <span class="token number">600</span>
  <span class="token key atrule">replicas</span><span class="token punctuation">:</span> <span class="token number">1</span>
<span class="token punctuation">...</span>
</code></pre>
<p>replicas &#x5B57;&#x6BB5;&#x8BBE;&#x7F6E;&#x4E86;&#x7EF4;&#x6301;&#x591A;&#x5C11;&#x4E2A; Pod &#x5B9E;&#x4F8B;&#xFF0C;&#x6240;&#x4EE5;&#x5F53; Pod &#x6302;&#x4E86;&#x540E;&#xFF0C;Deployment &#x4F1A;&#x91CD;&#x65B0;&#x521B;&#x5EFA;&#x4E00;&#x4E2A; Pod&#xFF0C;&#x800C;&#x4E0D;&#x662F;&#x4E24;&#x4E2A;&#xFF0C;&#x4E09;&#x4E2A;&#x3002;&#x8FD9;&#x4E2A;&#x5B57;&#x6BB5;&#x8DDF; ReplicaSet  &#x6709;&#x5173;&#xFF0C;&#x521B;&#x5EFA; Deployment &#x540E;&#xFF0C;&#x4F1A;&#x81EA;&#x52A8;&#x521B;&#x5EFA; ReplicaSet&#xFF0C;ReplicaSet &#x7BA1;&#x7406;&#x7684;&#x526F;&#x672C;&#x6570;&#x91CF;&#x8DDF; YAML <code>replicas</code> &#x5B57;&#x6BB5;&#x503C;&#x4E00;&#x81F4;&#x3002;</p>
<p>&#x67E5;&#x770B; replicaset &#x5B9E;&#x4F8B;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">root@slave1:~<span class="token comment"># kubectl get replicaset</span>
NAME               DESIRED   CURRENT   READY   AGE
nginx-55649fd747   <span class="token number">1</span>         <span class="token number">1</span>         <span class="token number">1</span>       22h
</code></pre>
<blockquote>
<p>replicaset &#x53EF;&#x7F29;&#x5199;&#x4E3A; rs&#xFF0C;&#x5373; <code>kubectl get rs</code>&#x3002;</p>
</blockquote>
<h3 id="&#x6269;&#x5BB9;-pod"><a name="&#x6269;&#x5BB9;-pod" class="anchor-navigation-ex-anchor" href="#&#x6269;&#x5BB9;-pod"><i class="fa fa-link" aria-hidden="true"></i></a>&#x6269;&#x5BB9; Pod</h3>
<p>&#x5728;&#x9879;&#x76EE;&#x521D;&#x671F;&#xFF0C;&#x7528;&#x6237;&#x4EBA;&#x6570;&#x5C11;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x5355;&#x4E2A;&#x5E94;&#x7528;&#x5B9E;&#x4F8B;&#x53EF;&#x80FD;&#x5C31;&#x6EE1;&#x8DB3;&#x4E86;&#x6240;&#x6709;&#x7528;&#x6237;&#x7684;&#x8BBF;&#x95EE;&#x9700;&#x6C42;&#x3002;</p>
<p><img src="images/pod_1.jpg" alt="pod_1"></p>
<p>&#x4F46;&#x662F;&#x968F;&#x7740;&#x65F6;&#x95F4;&#x53D1;&#x5C55;&#xFF0C;&#x7528;&#x6237;&#x6570;&#x91CF;&#x8D8A;&#x6765;&#x8D8A;&#x591A;&#xFF0C;&#x5355;&#x4E2A;&#x5E94;&#x7528;&#x65E0;&#x6CD5;&#x6491;&#x8D77;&#x9AD8;&#x5E76;&#x53D1;&#xFF0C;&#x8BBF;&#x95EE;&#x901F;&#x5EA6;&#x53D8;&#x6162;&#x4E86;&#xFF0C;&#x54CD;&#x5E94;&#x65F6;&#x95F4;&#x53D8;&#x957F;&#x4E86;&#xFF0C;&#x5185;&#x5B58;&#x7206;&#x70B8;&#x4E86;&#x3002;</p>
<p><img src="images/pod_100000000.png" alt="pod_100000000"></p>
<p>&#x8FD9;&#x4E2A;&#x65F6;&#x5019;&#xFF0C;&#x5982;&#x679C;&#x53EF;&#x4EE5;&#x63D0;&#x4F9B;&#x591A;&#x4E2A;&#x5B9E;&#x4F8B;&#xFF0C;&#x5219;&#x53EF;&#x4EE5;&#x5747;&#x5206;&#x7528;&#x6237;&#x7684;&#x8BBF;&#x95EE;&#x8BF7;&#x6C42;&#xFF0C;&#x8BA9;&#x4E00;&#x4E2A; Pod &#x53EA;&#x8D1F;&#x8F7D;&#x4E00;&#x90E8;&#x5206;&#x7528;&#x6237;&#xFF0C;&#x8FD9;&#x6837;&#x5C31;&#x80FD;&#x6709;&#x6548;&#x5730;&#x652F;&#x6301;&#x4EBF;&#x7EA7;&#x7528;&#x6237;&#x5E76;&#x53D1;&#x3002;</p>
<p><img src="images/pod_s.jpg" alt="pod_s"></p>
<p>&#x652F;&#x6301;&#x4EBF;&#x7EA7;&#x5E76;&#x53D1;&#xFF1F;&#x6709;&#x8FD9;&#x4E48;&#x7B80;&#x5355;&#x5417;&#xFF1F;&#x662F;&#x7684;&#xFF0C;&#x90E8;&#x7F72;&#x4E00;&#x767E;&#x4E07;&#x53F0;&#x670D;&#x52A1;&#x5668;&#x4E0D;&#x5C31;&#x884C;&#x4E86;&#xFF0C;&#x591A;&#x7B80;&#x5355;&#x3002;</p>
<blockquote>
<p><strong>[Info] &#x5F00;&#x73A9;&#x7B11;&#x7684;</strong></p>
<p>&#x7B14;&#x8005;&#x867D;&#x7136;&#x5B66;&#x4E86; Kubernetes &#x4EE5;&#x53CA;&#x5F88;&#x591A;&#x5730;&#x65B9;&#x52A8;&#x624B;&#x5B9E;&#x8DF5;&#x8FC7;&#xFF0C;&#x90FD;&#x662F;&#x4E9B;&#x5C0F;&#x9879;&#x76EE;&#xFF0C;&#x5BF9;&#x4F01;&#x4E1A;&#x7EA7;&#x7684; Kubernetes &#x5B8C;&#x5168;&#x6CA1;&#x7ECF;&#x9A8C;&#x3002;&#x4ECE;&#x522B;&#x7684;&#x5730;&#x65B9;&#x4E86;&#x89E3;&#x5230;&#xFF0C; Kubernetes &#x5355;&#x96C6;&#x7FA4;&#x662F;&#x6709;&#x4E00;&#x5B9A;&#x7A0B;&#x5EA6;&#x7684;&#x74F6;&#x9888;&#xFF0C;&#x673A;&#x5668;&#x6570;&#x91CF;&#x591A;&#x4E86;&#xFF0C;&#x6D41;&#x91CF;&#x5927;&#x4E86;&#xFF0C;&#x53EF;&#x80FD;&#x4F1A;&#x628A; Kubernetes &#x538B;&#x57AE;&#xFF0C;&#x4E8E;&#x662F;&#x53C8;&#x51FA;&#x73B0;&#x4E86;&#x591A;&#x96C6;&#x7FA4;&#x3001;&#x600E;&#x4E48;&#x5BF9;&#x591A;&#x96C6;&#x7FA4;&#x8D1F;&#x8F7D;&#x5747;&#x8861;&#x7B49;&#x3002;</p>
</blockquote>
<p>&#x56DE;&#x5F52;&#x6B63;&#x9898;&#xFF0C;&#x8981;&#x6269;&#x5C55; Pod &#x5B9E;&#x4F8B;&#xFF0C;&#x9700;&#x8981;&#x4FDD;&#x8BC1; Pod &#x5E94;&#x5F53;&#x662F;&#x65E0;&#x72B6;&#x6001;&#x7684;&#xFF0C;&#x5373;&#x6BCF;&#x4E2A; Pod &#x90FD;&#x662F;&#x4E00;&#x6837;&#x7684;&#xFF0C;&#x5B83;&#x4EEC;&#x4E0D;&#x80FD;&#x8868;&#x73B0;&#x51FA;&#x5DEE;&#x5F02;&#x6765;&#xFF0C;&#x540C;&#x4E00;&#x4E2A;&#x8BF7;&#x6C42;&#x65E0;&#x8BBA;&#x88AB;&#x54EA;&#x4E2A; Pod &#x5904;&#x7406;&#xFF0C;&#x5176;&#x54CD;&#x5E94;&#x7ED3;&#x679C;&#x90FD;&#x662F;&#x4E00;&#x81F4;&#x7684;&#x3002;</p>
<p>&#x5728; 1.4 &#x7AE0;&#x4E2D;&#xFF0C;&#x6839;&#x636E;&#x4E91;&#x539F;&#x751F;&#x5341;&#x4E8C;&#x56E0;&#x7D20;(<a href="https://12factor.net" target="_blank">https://12factor.net/</a>)&#x7684;&#x65B9;&#x6CD5;&#x8BBA;&#x548C;&#x6838;&#x5FC3;&#x601D;&#x60F3;&#xFF0C;&#x4E00;&#x4E2A; <code>Processes</code> &#x5E94;&#x5F53;&#x662F;&#x65E0;&#x72B6;&#x6001;&#x7684;&#xFF0C;&#x4EFB;&#x4F55;&#x6301;&#x4E45;&#x5316;&#x7684;&#x6570;&#x636E;&#x90FD;&#x8981;&#x5B58;&#x50A8;&#x5728;&#x540E;&#x7AEF;&#x670D;&#x52A1;&#x4E2D;&#x3002;A &#x955C;&#x50CF;&#xFF0C;&#x542F;&#x52A8; N &#x4E2A; docker &#x5BB9;&#x5668;&#xFF0C;&#x7AEF;&#x53E3;&#x4E3A; 801&#x3001;802&#x3001;803...&#xFF0C;&#x4ED6;&#x4EEC;&#x5176;&#x5B9E;&#x90FD;&#x662F;&#x4E00;&#x6837;&#x7684;&#xFF0C;&#x6211;&#x4EEC;&#x8BBF;&#x95EE;&#x54EA;&#x4E2A;&#x5BB9;&#x5668;&#xFF0C;&#x6700;&#x7EC8;&#x63D0;&#x4F9B;&#x7684;&#x670D;&#x52A1;&#x90FD;&#x662F;&#x4E00;&#x81F4;&#x7684;&#x3002;</p>
<p>&#x5982;&#x679C;&#x6211;&#x4EEC;&#x628A;&#x8FD9;&#x4E9B;&#x5BB9;&#x5668;&#x653E;&#x5230;&#x4E0D;&#x540C; Node &#x4E2D;&#xFF0C;&#x518D;&#x901A;&#x8FC7; k8s &#xFF0C;&#x5C31;&#x53EF;&#x4EE5;&#x4E3A;&#x591A;&#x4E2A;&#x5B9E;&#x4F8B;&#x4E4B;&#x95F4;&#x5206;&#x914D;&#x6D41;&#x91CF;&#xFF0C;&#x5373;&#x8D1F;&#x8F7D;&#x5747;&#x8861;&#x3002;&#x5373;&#xFF0C;<strong><span style="color:red;">&#x52A0;&#x673A;&#x5668;&#x5C31;&#x80FD;&#x89E3;&#x51B3;&#x95EE;&#x9898;</span></strong>&#x3002;</p>
<p>&#x5728; Deployment &#x4E2D;&#xFF0C;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x6307;&#x5B9A; YAML &#x6587;&#x4EF6;&#x7684; <code>.spec.replicas</code> &#x5B57;&#x6BB5;&#x6216;&#x8005;&#x4EE5;&#x547D;&#x4EE4;&#x53C2;&#x6570; <code>--replicas=</code> &#x8BBE;&#x7F6E;&#x526F;&#x672C;&#x6570;&#x91CF;&#x3002;</p>
<p>&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x52A8;&#x6001;&#x4FEE;&#x6539;&#x4E00;&#x4E2A; &#x63A7;&#x5236;&#x5668;&#x53EA;&#x80FD;&#x7684; Pod &#x6570;&#x91CF;&#xFF0C;&#x76F4;&#x63A5;&#x7F16;&#x8F91; YAML &#x6587;&#x4EF6;&#x5373;&#x53EF;&#xFF1A;</p>
<pre class="language-"><code>kubectl edit deployment nginx
</code></pre><p>&#x5728; <code>spec</code> &#x5B57;&#x6BB5;&#x540E;&#x9762;&#x627E;&#x5230; <code>replicas: 1</code>&#xFF0C;&#x4FEE;&#x6539;&#x4E3A; <code>replicas: 2</code>&#x3002;</p>
<p><img src="images/&#x4FEE;&#x6539;replicas.png" alt="&#x4FEE;&#x6539;replicas"></p>
<p>&#x518D;&#x6B21;&#x67E5;&#x770B; Deployment&#xFF1A;</p>
<pre class="language-"><code>root@instance-1:~# kubectl get deployments
NAME    READY   UP-TO-DATE   AVAILABLE   AGE
nginx   2/2     2            2           24m
</code></pre><blockquote>
<p>&#x5728;&#x521B;&#x5EFA; Deployment &#x65F6;&#xFF0C;&#x6211;&#x4EEC;&#x4E5F;&#x53EF;&#x4EE5;&#x4F7F;&#x7528; <code>--replicas=</code> &#x53C2;&#x6570;&#x51B3;&#x5B9A; Pod &#x7684;&#x526F;&#x672C;&#x6570;&#x91CF;&#x3002;</p>
<pre class="language-"><code>kubectl create deployment nginx --image=nginx:latest --replicas=2
</code></pre></blockquote>
<h3 id="scale"><a name="scale" class="anchor-navigation-ex-anchor" href="#scale"><i class="fa fa-link" aria-hidden="true"></i></a>Scale</h3>
<p>&#x524D;&#x9762;&#xFF0C;&#x5DF2;&#x7ECF;&#x901A;&#x8FC7;&#x4FEE;&#x6539; Deployment &#x5BF9;&#x8C61;&#x7684; YAML &#x6587;&#x4EF6;&#x5B9E;&#x73B0;&#x591A;&#x526F;&#x672C;&#x6269;&#x5BB9;&#xFF0C;&#x4F46;&#x662F;&#x6211;&#x4EEC;&#x603B;&#x4E0D;&#x80FD;&#x8001;&#x662F;&#x76F4;&#x63A5;&#x64CD;&#x4F5C; YAML &#x6587;&#x4EF6;&#x5427;&#xFF1F;Kubernetes &#x63D0;&#x4F9B;&#x4E86; <code>kubectl scale</code> &#x6269;&#x5BB9;&#x547D;&#x4EE4;&#xFF0C;&#x53EF;&#x4EE5;&#x4E3A;&#x6307;&#x5B9A;&#x5BF9;&#x8C61;&#x6269;&#x5BB9; Pod &#x6570;&#x91CF;&#x3002;</p>
<p>&#x4E3A; Deployment &#x5BF9;&#x8C61;&#x6269;&#x5BB9; Pod &#x6570;&#x91CF;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">kubectl scale deployment nginx --replicas<span class="token operator">=</span><span class="token number">3</span>
</code></pre>
<p>&#x7136;&#x540E;&#x7B49;&#x51E0;&#x79D2;&#x540E;&#x6267;&#x884C; <code>kubectl get deployments</code> &#x67E5;&#x770B;&#x7ED3;&#x679C;&#x3002;</p>
<pre class="language-"><code class="lang-bash">NAME    READY   UP-TO-DATE   AVAILABLE   AGE
nginx   <span class="token number">3</span>/3     <span class="token number">3</span>            <span class="token number">3</span>           3h15m
</code></pre>
<p>&#x67E5;&#x770B; ReplicaSet &#xFF1A;</p>
<pre class="language-"><code class="lang-bash">root@slave1:~<span class="token comment"># kubectl get rs</span>
NAME               DESIRED   CURRENT   READY   AGE
nginx-55649fd747   <span class="token number">3</span>         <span class="token number">3</span>         <span class="token number">3</span>       23h
</code></pre>
<p>&#x6267;&#x884C; <code>kubectl get pod -o wide</code> &#x53EF;&#x4EE5;&#x8F93;&#x51FA;&#x4FE1;&#x606F;&#x7684; pod &#x4FE1;&#x606F; &#x3002;</p>
<pre class="language-"><code>NAME       READY   STATUS   ESTARTS   AGE     IP              NODE     NOMINATED NODE   READINESS GATES
nginx-581   1/1     Running   0     3h11m   192.168.56.24   instance-2   <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>none</span><span class="token punctuation">&gt;</span></span>           <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>none</span><span class="token punctuation">&gt;</span></span>
nginx-582   1/1     Running   0     3m30s   192.168.56.25   instance-2   <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>none</span><span class="token punctuation">&gt;</span></span>           <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>none</span><span class="token punctuation">&gt;</span></span>
nginx-583   1/1     Running   0     3m30s   192.168.56.26   instance-2   <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>none</span><span class="token punctuation">&gt;</span></span>           <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>none</span><span class="token punctuation">&gt;</span></span>
# &#x6CE8;&#xFF0C;&#x7B14;&#x8005;&#x5220;&#x9664;&#x4E86;Name&#x7684;&#x90E8;&#x5206;&#x540D;&#x79F0;
</code></pre><p>&#x5F53;&#x6211;&#x4EEC;&#x4F7F;&#x7528; <code>kubectl delete xxx</code> &#x5220;&#x9664; pod &#x65F6;&#xFF0C;&#x6216;&#x8005; Pod &#x6545;&#x969C;&#x65F6;&#x3001;&#x624B;&#x8D31;&#x6539;&#x4E86; Pod &#x72B6;&#x6001;&#x65F6;&#xFF0C;Deployment &#x4F1A;&#x81EA;&#x52A8;&#x4FDD;&#x6301;&#x4E09;&#x4E2A;&#x526F;&#x672C;&#x96C6;&#xFF0C;&#x4F1A;&#x81EA;&#x52A8;&#x542F;&#x7528;&#x65B0;&#x7684; pod &#xFF0C;&#x4F60;&#x53EF;&#x4EE5;&#x5220;&#x9664;&#x5176;&#x4E2D;&#x4E00;&#x4E2A;&#x6216;&#x591A;&#x4E2A; Pod&#xFF0C;&#x518D;&#x67E5;&#x770B; Pod &#x6570;&#x91CF;&#xFF0C;&#x4F1A;&#x53D1;&#x73B0;&#x4E00;&#x76F4;&#x4FDD;&#x6301; 3 &#x4E2A;&#x3002;</p>
<p>ReplicaSet &#x53EF;&#x4EE5;&#x7B80;&#x5355;&#x5730;&#x8BBE;&#x7F6E;&#x526F;&#x672C;&#x6570;&#x91CF;&#xFF0C;&#x800C;&#x6211;&#x4EEC;&#x540E;&#x9762;&#x4F1A;&#x5B66;&#x4E60;&#x5230;&#x66F4;&#x52A0;&#x590D;&#x6742;&#x7684; Pod &#x6269;&#x5BB9;&#x6536;&#x7F29;&#x673A;&#x5236;&#x3002;</p>
<blockquote>
<p><code>kubectl scale</code> &#x547D;&#x4EE4;&#x4E5F;&#x53EF;&#x4F5C;&#x7528;&#x4E8E; ReplicaSet &#x548C; ReplicationController&#xFF0C;&#x4E24;&#x8005;&#x53EF;&#x7528;&#x7B80;&#x5316;&#x540D;&#x79F0; rs&#x3001;rc &#x4EE3;&#x66FF;&#x3002;</p>
<pre class="language-"><code>kubectl scale rc {&#x540D;&#x79F0;} --replicas=10
kubectl scale rs {&#x540D;&#x79F0;} --replicas=10
</code></pre></blockquote>
<h3 id="daemonset"><a name="daemonset" class="anchor-navigation-ex-anchor" href="#daemonset"><i class="fa fa-link" aria-hidden="true"></i></a>DaemonSet</h3>
<p>&#x5728; Kubernetes &#x4E2D;&#xFF0C;&#x8D1F;&#x8F7D;&#x7C7B;&#x578B;&#x6709; Deployments&#x3001;ReplicaSet&#x3001;DaemonSet&#x3001;StatefulSets &#x7B49;(&#x6216;&#x8005;&#x8BF4;&#x6709;&#x8FD9;&#x51E0;&#x4E2A;&#x63A7;&#x5236;&#x5668;)&#x3002;</p>
<p>&#x524D;&#x9762;&#x5DF2;&#x7ECF;&#x4ECB;&#x7ECD;&#x8FC7; Deployments &#x548C; ReplicaSet&#xFF0C;&#x5B83;&#x4EEC;&#x90FD;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x547D;&#x4EE4;&#x548C; YAML &#x521B;&#x5EFA;&#xFF0C;&#x4F46;&#x662F; ReplicaSet &#x4E00;&#x822C;&#x6CA1;&#x5FC5;&#x8981;&#x4F7F;&#x7528; YAML &#x521B;&#x5EFA;&#x7684;&#x3002;</p>
<p>DaemonSet &#x53EF;&#x4EE5;&#x786E;&#x4FDD;&#x4E00;&#x4E2A;&#x8282;&#x70B9;&#x53EA;&#x8FD0;&#x884C;&#x4E00;&#x4E2A; Pod &#x526F;&#x672C;&#x3002;</p>
<p>&#x5047;&#x5982;&#x6709;&#x4E2A; Pod&#xFF0C;&#x5F53;&#x65B0;&#x7684; &#x8282;&#x70B9;&#x52A0;&#x5165;&#x96C6;&#x7FA4;&#x65F6;&#xFF0C;&#x4F1A;&#x81EA;&#x52A8;&#x5728;&#x8FD9;&#x4E2A; &#x8282;&#x70B9; &#x4E0A;&#x90E8;&#x7F72;&#x4E00;&#x4E2A; Pod&#xFF1B;&#x5F53;&#x8282;&#x70B9;&#x4ECE;&#x96C6;&#x7FA4;&#x4E2D;&#x79FB;&#x5F00;&#x65F6;&#xFF0C;&#x8FD9;&#x4E2A; Node &#x4E0A;&#x7684; Pod &#x4F1A;&#x88AB;&#x56DE;&#x6536;&#xFF1B;&#x5982;&#x679C; DaemontSet &#x914D;&#x7F6E;&#x88AB;&#x5220;&#x9664;&#xFF0C;&#x5219;&#x4E5F;&#x4F1A;&#x5220;&#x9664;&#x6240;&#x6709;&#x7531;&#x5B83;&#x521B;&#x5EFA;&#x7684; Pod&#x3002;DaemonSet &#x65E0;&#x89C6;&#x8282;&#x70B9;&#x7684;&#x6392;&#x65A5;&#x6027;&#xFF0C;&#x5373; &#x8282;&#x70B9;&#x53EF;&#x4EE5;&#x6392;&#x65A5;&#x8C03;&#x5EA6;&#x5668;&#x5728;&#x6B64;&#x8282;&#x70B9;&#x4E0A;&#x90E8;&#x7F72; Pod&#xFF0C;DaemonSet &#x5219;&#x4F1A;&#x7ED5;&#x8FC7;&#x8C03;&#x5EA6;&#x5668;&#xFF0C;&#x5F3A;&#x884C;&#x90E8;&#x7F72;&#x3002;Kubernetes &#x7684;&#x4E00;&#x4E9B;&#x7CFB;&#x7EDF;&#x670D;&#x52A1;&#xFF0C;&#x4E5F;&#x662F; DaemonSet &#x90E8;&#x7F72;&#x6A21;&#x5F0F;&#x3002;</p>
<p>DaemonSet &#x7684;&#x4E00;&#x4E9B;&#x5178;&#x578B;&#x7528;&#x6CD5;&#xFF1A;</p>
<ul>
<li>&#x5728;&#x6BCF;&#x4E2A;&#x8282;&#x70B9;&#x4E0A;&#x8FD0;&#x884C;&#x96C6;&#x7FA4;&#x5B88;&#x62A4;&#x8FDB;&#x7A0B;</li>
<li>&#x5728;&#x6BCF;&#x4E2A;&#x8282;&#x70B9;&#x4E0A;&#x8FD0;&#x884C;&#x65E5;&#x5FD7;&#x6536;&#x96C6;&#x5B88;&#x62A4;&#x8FDB;&#x7A0B;</li>
<li>&#x5728;&#x6BCF;&#x4E2A;&#x8282;&#x70B9;&#x4E0A;&#x8FD0;&#x884C;&#x76D1;&#x63A7;&#x5B88;&#x62A4;&#x8FDB;&#x7A0B;</li>
</ul>
<p>&#x5728; yaml &#x4E2D;&#xFF0C;&#x8981;&#x914D;&#x7F6E; Daemont&#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528; <code>tolerations</code>&#xFF0C;&#x914D;&#x7F6E;&#x793A;&#x4F8B;&#xFF1A;</p>
<pre class="language-"><code class="lang-yaml"><span class="token key atrule">kind</span><span class="token punctuation">:</span> DaemontSet
<span class="token punctuation">...</span> <span class="token punctuation">...</span>
</code></pre>
<p>&#x5176;&#x5B83;&#x5730;&#x65B9;&#x8DDF; Deployment &#x4E00;&#x81F4;&#xFF0C;&#x8FD9;&#x91CC;&#x636E;&#x4E0D;&#x591A;&#x8BF4;&#x4E86;&#xFF0C;&#x8BFB;&#x8005;&#x4E86;&#x89E3;&#x5373;&#x53EF;&#x3002;</p>
<p>&#x5173;&#x4E8E; 3.10 &#x7AE0;&#x4F1A;&#x63D0;&#x53CA;&#x3002;</p>
<h3 id="&#x8D1F;&#x8F7D;&#x5747;&#x8861;"><a name="&#x8D1F;&#x8F7D;&#x5747;&#x8861;" class="anchor-navigation-ex-anchor" href="#&#x8D1F;&#x8F7D;&#x5747;&#x8861;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x8D1F;&#x8F7D;&#x5747;&#x8861;</h3>
<p>&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x901A;&#x8FC7; Deployment&#xFF0C;&#x6216;&#x8005; DaemonSet&#xFF0C;&#x4E3A; Pod &#x521B;&#x5EFA;&#x591A;&#x4E2A;&#x526F;&#x672C;&#xFF0C;&#x8FD9;&#x4E9B; Pod &#x526F;&#x672C;&#x5B9E;&#x4F8B;&#xFF0C;&#x4F1A;&#x81EA;&#x52A8;&#x5206;&#x5230;&#x5404;&#x4E2A;&#x8282;&#x70B9;&#x4E0A;&#x3002;</p>
<p><img src="images/fzjh1 (2" alt="fzjh1">.png&gt;)</p>
<p>&#x521B;&#x5EFA;&#x591A;&#x4E2A; Pod &#x80FD;&#x591F;&#x5B9E;&#x73B0;&#x8D1F;&#x8F7D;&#x5747;&#x8861;&#x7684;&#x539F;&#x56E0;&#x65F6; Pod &#x88AB;&#x5206;&#x914D;&#x5230;&#x591A;&#x4E2A;&#x8282;&#x70B9;&#x4E2D;&#xFF0C;&#x5229;&#x7528;&#x4E86;&#x591A;&#x53F0;&#x670D;&#x52A1;&#x5668;&#x7684;&#x8BA1;&#x7B97;&#x8D44;&#x6E90;&#xFF0C;&#x672C;&#x8D28;&#x662F;&#x5206;&#x914D;&#x66F4;&#x591A;&#x7684;&#x8D44;&#x6E90;&#xFF0C;&#x5982;&#x679C;&#x53EA;&#x6709;&#x4E00;&#x4E2A;&#x670D;&#x52A1;&#x5668;&#xFF0C;&#x90A3;&#x4E48;&#x518D;&#x6269;&#x5BB9; Pod &#xFF0C;&#x80FD;&#x591F;&#x4F7F;&#x7528;&#x7684;&#x8D44;&#x6E90;&#x662F;&#x6709;&#x9650;&#x7684;&#xFF0C;&#x4E0D;&#x4F1A;&#x5E26;&#x6765;&#x4EC0;&#x4E48;&#x6548;&#x679C;&#x3002;&#x5F53;&#x7136;&#xFF0C;&#x5982;&#x679C; Pod &#x88AB;&#x8BBE;&#x7F6E;&#x4E86;&#x8D44;&#x6E90;&#x9650;&#x5236;&#xFF0C;&#x53EA;&#x8981;&#x8BE5;&#x670D;&#x52A1;&#x5668;&#x4E0A;&#x8FD8;&#x6709;&#x5269;&#x4F59;&#x8D44;&#x6E90;&#xFF0C;&#x90A3;&#x4E48;&#x5206;&#x914D;&#x66F4;&#x591A;&#x7684; Pod&#xFF0C;&#x4E5F;&#x662F;&#x6709;&#x6548;&#x7684;&#x3002;&#x8FD9;&#x70B9;&#x6211;&#x4EEC;&#x540E;&#x9762;&#x7684;&#x7AE0;&#x8282;&#x518D;&#x8BB2;&#x89E3;&#x3002;</p>
<p>Pod &#x5B9E;&#x4F8B;&#x6570;&#x91CF;&#x662F;&#x591A;&#x4E86;&#xFF0C;&#x4E5F;&#x5206;&#x914D;&#x5230;&#x4E0D;&#x540C;&#x7684; &#x8282;&#x70B9;&#x4E0A;&#xFF0C;&#x4F46;&#x662F;&#x6211;&#x4EEC;&#x600E;&#x4E48;&#x8BBF;&#x95EE; Pod&#xFF1F;&#x96BE;&#x9053; 2 &#x4E2A;&#x8282;&#x70B9;&#xFF0C;&#x6211;&#x4EEC;&#x8981;&#x5355;&#x72EC;&#x8BBF;&#x95EE; IP&#xFF1F;</p>
<p>&#x5176;&#x5B9E;&#x6211;&#x4EEC;&#x65E0;&#x9700;&#x62C5;&#x5FC3;&#x592A;&#x591A;&#xFF0C;&#x56E0;&#x4E3A; Kubernetes &#x63D0;&#x4F9B;&#x4E86; Service&#x3001;Ingress &#x7B49;&#x7F51;&#x7EDC;&#x670D;&#x52A1;&#xFF0C;&#x6211;&#x4EEC;&#x4EE5; Service &#x4E3E;&#x4F8B;&#x3002;</p>
<p>Pod &#x63D0;&#x4F9B;&#x4E86;&#x4E00;&#x4E2A; 8080&#x7AEF;&#x53E3;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x521B;&#x5EFA;&#x4E00;&#x4E2A; Service&#xFF0C;&#x8FD9;&#x4E2A; Service &#x5BF9;&#x5916;&#x4E5F;&#x63D0;&#x4F9B;&#x4E86; 8080 &#x7AEF;&#x53E3;&#xFF0C;&#x5F53;&#x7528;&#x6237;&#x8BBF;&#x95EE;&#x516C;&#x7F51; <code>IP:8080</code> &#x65F6;&#xFF0C;Service &#x4F1A;&#x968F;&#x673A;&#x9009;&#x62E9;&#x4E00;&#x4E2A; Pod &#x4E3A;&#x7528;&#x6237;&#x63D0;&#x4F9B;&#x670D;&#x52A1;&#xFF0C;&#x6211;&#x4EEC;&#x65E0;&#x9700;&#x5173;&#x6CE8;&#x8BBF;&#x95EE;&#x4E86;&#x54EA;&#x4E2A; Pod&#x3002;</p>
<p><img src="images/fzjh2.png" alt="fzjh2"></p>
<p>&#x4E0D;&#x8FC7; Deployment &#x90E8;&#x7F72;&#x7684; Pod&#xFF0C;&#x5047;&#x5982;&#x6709; 5 &#x4E2A;&#x8282;&#x70B9;&#xFF0C;&#x8981;&#x90E8;&#x7F72; 5 &#x4E2A; Pod&#xFF0C;&#x4E0D;&#x4F1A;&#x6BCF;&#x4E2A;&#x8282;&#x70B9;&#x90FD;&#x521A;&#x597D;&#x6709;&#x4E00;&#x4E2A; Pod&#x3002;&#x540C;&#x6837;&#xFF0C;5 &#x4E2A;&#x8282;&#x70B9;&#xFF0C;10 &#x4E2A; Pod&#xFF0C;&#x4E0D;&#x4E00;&#x5B9A;&#x6BCF;&#x4E2A; &#x8282;&#x70B9;&#x90FD;&#x6709;&#x4E24;&#x4E2A; Pod&#x3002;&#x5982;&#x679C;&#x6211;&#x4EEC;&#x9700;&#x8981; Pod &#x80FD;&#x591F;&#x5E73;&#x5747;&#x5730;&#x5206;&#x914D;&#x5230; &#x8282;&#x70B9;&#x4E2D;&#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528; DaemonSet&#x3002;</p>
<h3 id="replicationcontroller-&#x548C;-replicaset"><a name="replicationcontroller-&#x548C;-replicaset" class="anchor-navigation-ex-anchor" href="#replicationcontroller-&#x548C;-replicaset"><i class="fa fa-link" aria-hidden="true"></i></a>ReplicationController &#x548C; ReplicaSet</h3>
<p>ReplicationController&#x3001;ReplicaSet &#x90FD;&#x662F; Kubernetes &#x91CC;&#x9762;&#x7684;&#x526F;&#x672C;&#x7BA1;&#x7406;&#x673A;&#x5236;&#xFF0C;&#x80FD;&#x591F;&#x4FDD;&#x8BC1;&#x6700;&#x7EC8;&#x5177;&#x6709;&#x4E00;&#x5B9A;&#x6570;&#x91CF;&#x7684; Pod &#x5904;&#x4E8E;&#x8FD0;&#x884C;&#x72B6;&#x6001;&#x4E2D;&#xFF0C;&#x5F53;&#x8282;&#x70B9;&#x6545;&#x969C;&#x6216;&#x8005; Pod &#x6545;&#x969C;&#x65F6;&#x3001;Pod &#x88AB;&#x8282;&#x70B9;&#x9010;&#x51FA;&#x65F6;&#xFF0C;&#x80FD;&#x591F;&#x53CA;&#x65F6;&#x5728;&#x5176;&#x5B83;&#x8282;&#x70B9;&#x4E0A;&#x6062;&#x590D;&#x4E00;&#x5B9A;&#x6570;&#x91CF;&#x7684; Pod &#x5B9E;&#x4F8B;&#x3002;</p>
<p>ReplicationController &#x51FA;&#x73B0;&#x8F83;&#x65E9;&#xFF0C;&#x540E;&#x9762;&#x51FA;&#x73B0;&#x4E86; ReplicaSet &#x7528;&#x4E8E;&#x66FF;&#x4EE3;&#x5B83;&#x3002;&#x4ECE;&#x4E2D;&#x6587;&#x7FFB;&#x8BD1;&#x6765;&#x770B;&#xFF0C;ReplicationController &#x8BD1;&#x4E3A; &#x590D;&#x5236;&#x63A7;&#x5236;&#x5668;&#xFF0C;ReplicaSet &#x8BD1;&#x4E3A; &#x526F;&#x672C;&#x96C6;&#x3002;&#x4E24;&#x8005;&#x4E3B;&#x8981;&#x533A;&#x522B;&#x662F;&#x9009;&#x62E9;&#x5668;&#x652F;&#x6301;&#xFF0C;&#x5728; <a href="https://github.com/whuanle/kubernetes_ckad/tree/2952854b09e0e28859774b48b508f6f02669066f/3.pod/3.7label.md" target="_blank">3.7 &#x6807;&#x7B7E;</a> &#x3001;<a href="8.schedule.html">3.8 &#x8C03;&#x5EA6;</a> &#x4E24;&#x7AE0;&#xFF0C;&#x4F60;&#x53EF;&#x4EE5;&#x4E86;&#x89E3;&#x6807;&#x7B7E;&#x548C;&#x9009;&#x62E9;&#x5668;&#x7684;&#x4F7F;&#x7528;&#x65B9;&#x6CD5;&#x3002;</p>
<p>ReplicationController &#x53EA;&#x652F;&#x6301;&#x7B49;&#x503C;&#x9009;&#x62E9;&#x5668;&#xFF0C;&#x793A;&#x4F8B;&#xFF1A;</p>
<pre class="language-"><code>environment = production
</code></pre><p>ReplicaSet &#x652F;&#x6301;&#x57FA;&#x4E8E;&#x96C6;&#x5408;&#x7684;&#x9009;&#x62E9;&#x5668;&#xFF1A;</p>
<pre class="language-"><code>environment in (production, qa)
</code></pre><p>&#x53E6;&#x5916;&#x5C31;&#x662F; ReplicaSet &#x4E00;&#x822C;&#x4E0D;&#x5355;&#x72EC;&#x4F7F;&#x7528;&#xFF0C;&#x800C;&#x662F;&#x7ED3;&#x5408; Deployment &#x7B49;&#x4E00;&#x8D77;&#x4F7F;&#x7528;&#x3002;</p>
<blockquote>
<p>ReplicaSet &#x867D;&#x7136;&#x662F; ReplicationController &#x7684;&#x66FF;&#x4EE3;&#x65B9;&#x6848;&#xFF0C;&#x4F46;&#x662F;&#x4E24;&#x8005;&#x5C5E;&#x4E8E;&#x4E0D;&#x540C;&#x7684;&#x8D44;&#x6E90;&#x3002;</p>
<pre class="language-"><code class="lang-bash">root@instance-2:~<span class="token comment"># kubectl get replicationcontroller</span>
No resources found <span class="token keyword">in</span> default namespace.
root@instance-2:~<span class="token comment"># kubectl get replicaset</span>
NAME                    DESIRED   CURRENT   READY   AGE
nginxtaint-6c6dd878f9   <span class="token number">5</span>         <span class="token number">5</span>         <span class="token number">5</span>       2d19h
</code></pre>
</blockquote>
<p>&#x65E2;&#x7136; ReplicationController &#x8981;&#x6DD8;&#x6C70;&#x4E86;&#xFF0C;&#x90A3;&#x4E48;&#x5728;&#x672C;&#x7AE0;&#x4EE5;&#x53CA;&#x540E;&#x9762;&#x7AE0;&#x8282;&#xFF0C;&#x53EA;&#x4F1A;&#x8BA8;&#x8BBA; ReplicaSet&#x3002;</p>
<footer class="page-footer"><span class="copyright">Copyright &#xA9; &#x75F4;&#x8005;&#x5DE5;&#x826F; 2021 all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x6587;&#x6863;&#x6700;&#x540E;&#x66F4;&#x65B0;&#x65F6;&#x95F4;&#xFF1A;
2021-11-17 07:18:34
</span></footer>
<script>console.log("plugin-popup....");document.onclick = function(e){ e.target.tagName === "IMG" && window.open(e.target.src,e.target.src)}</script><style>img{cursor:pointer}</style>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="2.deployment.html" class="navigation navigation-prev " aria-label="Previous page: 3.2 Deployment部署">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="4.pod_network.html" class="navigation navigation-next " aria-label="Next page: 3.34 Pod 端口映射">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"3.3 副本集(ReplicaSet)","level":"1.4.4","depth":2,"next":{"title":"3.34 Pod 端口映射","level":"1.4.5","depth":2,"path":"3.pod/4.pod_network.md","ref":"3.pod/4.pod_network.md","articles":[]},"previous":{"title":"3.2 Deployment部署","level":"1.4.3","depth":2,"path":"3.pod/2.deployment.md","ref":"3.pod/2.deployment.md","articles":[]},"dir":"ltr"},"config":{"plugins":["tbfed-pagefooter","anchor-navigation-ex","mermaid-gb3","insert-logo","chapter-fold","advanced-emoji","github","splitter","alerts","popup","prism","-highlight","livereload"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"Copyright &copy 痴者工良 2021","modify_label":"文档最后更新时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"chapter-fold":{},"prism":{"lang":{"flow":"typescript","shell":"bash"},"ignore":["mermaid","eval-js"],"css":["prismjs/themes/prism.css"],"js":["prismjs/prism.js","prismjs/components.js","prismjs/components/prism-go.min.js","prismjs/components/prism-yaml.min.js","prismjs/components/prism-bash.min.js","prismjs/components/prism-shell-session.min.js"]},"github":{"url":"https://github.com/whuanle/kubernetes"},"livereload":{},"splitter":{},"search":{},"popup":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"mermaid-gb3":{},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":false,"showLevel":false},"alerts":{},"advanced-emoji":{"embedEmojis":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"insert-logo":{"style":"background: none; max-height: 50px; min-height: 50px","url":"/images/logo.jpg"}},"theme":"default","author":"痴者工良","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Kubernetes - 痴者工良","language":"zh-hans","links":{"sidebar":{"痴者工良的博客":"https://www.whuanle.cn"}},"gitbook":"*","description":"这是一本关于 Kubernetes 的书，作者 痴者工良"},"file":{"path":"3.pod/3.replica.md","mtime":"2021-11-16T23:18:34.622Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-11-16T23:21:22.294Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-mermaid-gb3/book/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-insert-logo/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-github/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-alerts/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    <script src="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.min.js"></script>

    </body>
</html>

